package csel.view;

import java.awt.GridLayout;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import csel.model.Entity;
import csel.model.Observer;

/*
 * Reasons for Existence: 
 * Team Members Responsible
 * Implementation: Alex, Andrew
 * Testing: Alex, Andrew
 */
public class StatsViewer extends JPanel implements Observer
{
	
	JLabel lives;
    JLabel strength;
    JLabel agility;
    JLabel intellect;
    JLabel hardiness;
    JLabel experience;
    JLabel movement;
    JLabel level;
    JLabel life;
    JLabel mana;
    JLabel offensiveRating;
    JLabel defensiveRating;
    JLabel armorRating;
    
    JLabel livesV;
    JLabel strengthV;
    JLabel agilityV;
    JLabel intellectV;
    JLabel hardinessV;
    JLabel experienceV;
    JLabel movementV;
    JLabel levelV;
    JLabel lifeV;
    JLabel manaV;
    JLabel offensiveRatingV;
    JLabel defensiveRatingV;
    JLabel armorRatingV;
	
    JPanel labelsPane;
    JPanel valuesPane;
    
	public StatsViewer(Entity e)
	{
		e.addObserver(this);
		
        setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
        
        labelsPane = new JPanel();
        valuesPane = new JPanel();
        
        labelsPane.setLayout(new BoxLayout(labelsPane,BoxLayout.Y_AXIS));
        valuesPane.setLayout(new BoxLayout(valuesPane,BoxLayout.Y_AXIS));
        
        labelsPane.setOpaque(false);
        valuesPane.setOpaque(false);
        
        modelUpdate(e);
        
        add(labelsPane);
        add(valuesPane);
	}

	public void setEntity(Entity e)
	{
		e.addObserver(this);
		modelUpdate(e);
	}
	
	public void modelUpdate(Object o)
	{
		Entity e = ((Entity) o);
		
		labelsPane.removeAll();
		valuesPane.removeAll();
		
		lives = new JLabel("Lives Left:");
	    strength = new JLabel("Strength:");
	    agility = new JLabel("Agility:");
	    intellect = new JLabel("Intellect:");
	    hardiness = new JLabel("Hardiness:");
	    experience = new JLabel("Experience:");
	    movement = new JLabel("Movement:");
	    level = new JLabel("Level:");
	    life = new JLabel("Life:");
	    mana = new JLabel("Mana:");
	    offensiveRating = new JLabel("Offensive Rating:");
	    defensiveRating = new JLabel("Defensive Rating:");
	    armorRating = new JLabel("Armor Rating:");
	    
	    labelsPane.add(lives);
	    labelsPane.add(strength);
	    labelsPane.add(agility);
	    labelsPane.add(intellect);
	    labelsPane.add(hardiness);
	    labelsPane.add(experience);
	    labelsPane.add(movement);
	    labelsPane.add(level);
	    labelsPane.add(life);
	    labelsPane.add(mana);
	    labelsPane.add(offensiveRating);
	    labelsPane.add(defensiveRating);
	    labelsPane.add(armorRating);
	    
	    livesV = new JLabel(Integer.toString(e.getLives()));
	    strengthV = new JLabel(Integer.toString(e.getStrength()));
	    agilityV = new JLabel(Integer.toString(e.getAgility()));
	    intellectV = new JLabel(Integer.toString(e.getIntellect()));
	    hardinessV = new JLabel(Integer.toString(e.getHardiness()));
	    experienceV = new JLabel(Integer.toString(e.getExperience()));
	    movementV = new JLabel(Integer.toString(e.getSpeed()));
	    levelV = new JLabel(Integer.toString(e.getLevel()));
	    lifeV = new JLabel(Integer.toString(e.getLife()));
	    manaV = new JLabel(Integer.toString(e.getMana()));
	    offensiveRatingV = new JLabel(Integer.toString(e.getOffense()));
	    defensiveRatingV = new JLabel(Integer.toString(e.getDefense()));
	    armorRatingV = new JLabel(Integer.toString(e.getArmor()));
	   
	    valuesPane.add(livesV);
	    valuesPane.add(strengthV);
	    valuesPane.add(agilityV);
	    valuesPane.add(intellectV);
	    valuesPane.add(hardinessV);
	    valuesPane.add(experienceV);
	    valuesPane.add(movementV);
	    valuesPane.add(levelV);
	    valuesPane.add(lifeV);
	    valuesPane.add(manaV);
	    valuesPane.add(offensiveRatingV);
	    valuesPane.add(defensiveRatingV);
	    valuesPane.add(armorRatingV);
	    
	    revalidate();
        //repaint();
	}
}
